#pragma once

#include <QBrush>
#include <QColor>
#include <QDebug>
#include <QDesktopServices>
#include <QFont>
#include <QHeaderView>
#include <QMainWindow>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QUrl>
#include <memory>
#include <string>
#include <vector>

#include "DataMgr.h"
#include "QCheckBox"

class WidgetPanel;
enum class SortMethod
{
    N,
    S,
	NS

};

struct ColumnInfo
{
    QString strLabel;
    SortMethod sort;
    int nWidth = 0;
};

enum TableMode
{
	CF,
	CFSomeOne,
	ATCoder
};
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);

    void setupUI();
    void setTableMode(TableMode mode);

private slots:
    void onCellClicked(int row, int column);
    void onHeaderClicked(int logicalIndex);

public:
    std::vector<QTableWidgetItem *> appendOneRow(
        int nRow, const QStringList &lstText, bool bCF,
        const QColor &clrText = Qt::white, const QColor &clrBK = Qt::black);

    QTableWidget *tableWidget;
    QWidget *m_wdgPanel = nullptr;
    std::vector<CFProblem> problems;
    WidgetPanel *m_panel;

    std::vector<ColumnInfo> m_vecColumn;
};
